package com.sunrise.xdoc.entity.store;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cascade;

@Entity
@Table(name = "store_phieu_xuat_kho")
@Inheritance(strategy = InheritanceType.JOINED)
public class PhieuXuatKho extends AbstractPhieuKho {
	private static final long serialVersionUID = 2932177777814730896L;

	private LyDoXuatKho lyDo = LyDoXuatKho.BAN_HANG;

	private List<ChiTietXuatKho> chiTietXuatKhos;

	@Enumerated(EnumType.STRING)
	@Column(name = "ly_do")
	@NotNull
	public LyDoXuatKho getLyDo() {
		return lyDo;
	}

	public void setLyDo(LyDoXuatKho lyDo) {
		this.lyDo = lyDo;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "phieuXuatKho")
	@Cascade(value = { org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.DELETE })
	public List<ChiTietXuatKho> getChiTietXuatKhos() {
		return chiTietXuatKhos;
	}

	public void setChiTietXuatKhos(List<ChiTietXuatKho> chiTietXuatKhos) {
		this.chiTietXuatKhos = chiTietXuatKhos;
	}

}
